
package com.hunqing.user.service;

import java.util.ArrayList;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hunqing.common.framework.dao.DaoSupport;
import com.hunqing.user.entity.User;

@Service
public class UserService extends DaoSupport<User> implements IUserService {

	@PersistenceContext
	EntityManager em;

	public boolean checkOk(String userName, String passWord) throws Exception {

		long count = (Long) em.createQuery("select count(*) from User  o where o.userName=?1 and o.passWord=?2 ")
				.setParameter(1, userName).setParameter(2, passWord).getSingleResult();
		return count>0;
	}

	public boolean exist(String userName) throws Exception {
		long count = (Long) em.createQuery("select count(o) from User o where o.userName=?1").setParameter(1, userName)
				.getSingleResult();
		return count > 0;
	}

}
